﻿CREATE PROCEDURE [dbo].[proc_Order_FinalPayment_Create]
	(
		@OId uniqueidentifier
		,@CusId	uniqueidentifier
		,@CusName nvarchar(50)
		,@SalesmanAccount nvarchar(50)
		,@Salesman nvarchar(50)
		,@CreateDate datetime
		,@Prices decimal(18, 2)
		,@PaymentTypeId	int
		,@PaymentType nvarchar(50)
		,@BankId int
		,@Bank nvarchar(50)
		,@SWId int
		,@SWName nvarchar(50)
		,@shjbh varchar(50)
		,@FinanceFlag bit
		,@CompanyId	int
		,@Description nvarchar(200)
	)
AS
Begin

Declare @Shl int
Select @Shl=Count(0) From Order_PaymentRecord Where OId=@OId And SWId=2 And FinanceDate Is Null
If @Shl>0
Begin
	Select @Shl As shl
	Return
End
Else
Begin
	Insert Into Order_PaymentRecord
	(
		OId
		,CusId
		,CusName
		,SalesmanAccount
		,Salesman
		,CreateDate
		,Prices
		,PaymentTypeId
		,PaymentType
		,BankId
		,Bank
		,SWId
		,SWName
,shjbh
		,FinanceFlag
		,CompanyId
		,Description
	)
	Values
	(
		@OId
		,@CusId
		,@CusName
		,@SalesmanAccount
		,@Salesman
		,@CreateDate
		,@Prices
		,@PaymentTypeId
		,@PaymentType
		,@BankId
		,@Bank
		,@SWId
		,@SWName
,@shjbh
		,@FinanceFlag
		,@CompanyId
		,@Description
	)
	Select 0 As shl
	Return
End
End